package com.czk.netty.netty.http.tomcat;

import io.netty.handler.codec.http.HttpRequest;

import java.util.Objects;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/2/22 20:42
 */
public abstract class MyRequest {
    /**
     * geta方法
     */
    public abstract void doGet(HttpRequest httpRequest);

    /**
     * post方法
     */
    public abstract void doPost(HttpRequest httpRequest);

    /**
     * service方法
     *
     * @param httpRequest
     */
    public void service(HttpRequest httpRequest) {
        // 拿到方法
        String name = httpRequest.method().name();
        // 封装路
        if (Objects.equals(name, "POST")) {
            doPost(httpRequest);
        }
        if (Objects.equals(name, "GET")) {
            doGet(httpRequest);
        }
    }
}
